package com.probox.modules.controller.customer;

import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.core.web.page.TableDataInfo;
import com.probox.common.log.annotation.Log;
import com.probox.common.log.enums.BusinessType;
import com.probox.common.security.annotation.PreAuthorize;
import com.probox.common.entity.domain.customer.CustomerOperation;
import com.probox.common.entity.service.customer.ICustomerOperationService;
import com.probox.common.entity.vo.customer.CustomerOperationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 客户运营Controller
 *
 * @author usoft
 * @date 2021-07-23
 */
@RestController
@RequestMapping("/customer/CustomerOperation")
public class CustomerOperationController extends BaseController {
    @Autowired
    private ICustomerOperationService customerOperationService;

    /**
     * 查询客户运营列表
     */
    @PreAuthorize(hasPermi = "CustomerOperation:CustomerOperation:list")
    @GetMapping("/list")
    public TableDataInfo list(CustomerOperation customerOperation) {
        startPage();
        List<CustomerOperation> list = customerOperationService.queryList(customerOperation);
        return getDataTable(list);
    }


    /**
     * 获取客户运营详细信息
     */
    @PreAuthorize(hasPermi = "CustomerOperation:CustomerOperation:query")
    @GetMapping(value = "/{operationUid}")
    public AjaxResult getInfo(@PathVariable("operationUid") Long operationUid) {
        return AjaxResult.success(customerOperationService.selectCustomerOperationById(operationUid));
    }

    /**
     * 删除客户运营
     */
    @PreAuthorize(hasPermi = "CustomerOperation:CustomerOperation:remove")
    @Log(title = "客户运营", businessType = BusinessType.DELETE)
    @DeleteMapping("/{operationUids}")
    public AjaxResult remove(@PathVariable Long[] operationUids) {
        return toAjax(customerOperationService.deleteCustomerOperationByIds(operationUids));
    }

    /**
     * 新增客户运营
     */
    @PreAuthorize(hasPermi = "CustomerOperation:CustomerOperation:add")
    @Log(title = "客户运营", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerOperationVo customerOperationVo) {
        return toAjax(customerOperationService.insertCustomerOperation(customerOperationVo));
    }

    /**
     * 修改客户运营
     */
    @PreAuthorize(hasPermi = "CustomerOperation:CustomerOperation:edit")
    @Log(title = "客户运营", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerOperationVo customerOperationVo) {
        return toAjax(customerOperationService.updateCustomerOperation(customerOperationVo));
    }

    /**
     * 测试处理mq消息
     */
    @GetMapping("/consumptionOpearationMsg/{operationUid}")
    public AjaxResult consumptionOpearationMsg(@PathVariable("operationUid") Long operationUid) {
        return toAjax(customerOperationService.consumptionOpearationMsg(operationUid));
    }



}
